<template>
    <el-container class="home-container">
        <el-header>
                <div>
                    <span>物业管理系统</span>
                </div>
                <el-button type="info" @click="logout">退出</el-button>
        </el-header>
        <el-container>
            <el-aside style="width:250px; border-right: 0px;">
                <el-menu router
                         default-active="2"
                         class="el-menu-vertical-demo"
                         background-color="#333744"
                         text-color="#fff"
                         active-text-color="#409FFF">
                    <el-submenu v-for="(item,index) in $router.options.routes" :index="index+''" v-if="item.show">
                        <template slot="title"><i :class="'el-icon-'+item.icon"></i><span>{{item.name}}</span></template>
                        <el-menu-item v-for="(item2,index2) in item.children" :index="item2.path"
                                      :class="$route.path==item2.path?'is-active':''"><i :class="'el-icon-'+item2.icon"></i><span>{{item2.name}}</span></el-menu-item>
                    </el-submenu>
                </el-menu>
            </el-aside>
            <el-main>
                <router-view></router-view>
            </el-main>
        </el-container>
    </el-container>
</template>

<script>
    import router, {createRouter} from "../router";

    export default {
        methods:{
            logout(){
                window.sessionStorage.clear()
                // this.$router.go(0)
                this.$router.push('/login')
            }
        }
    }
</script>

<style lang="less" scoped>
    .el-menu{
        border: solid 0px;
    }
    .home-container{
        height: 100%;
    }
    .el-header{
        background-color: #373d41;
        display: flex;
        justify-content: space-between;
        padding-left: 0 ;
        align-items: center;
        color: #ffffff;
        font-size: 20px;
        >div{
            display: flex;
            align-items: center;
            span{
                margin-left: 15px;
            }
        }
    }

    .el-aside{
        background-color: #333744;
        margin:0px 0px 0px 0px;
    }
    .el-main{
        background-color: #eaedf1;
    }
    .span-length{
        margin-left: 10px;
    }
    .el-menu-item{
        margin-left: 10px;
    }
</style>
